﻿<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>发布拼单 - 模切材料小管家</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        :root {
            /* TDesign 工业品色彩系统 */
            --primary-color: #0052d9;
            --primary-light: #266fe8;
            --primary-dark: #003cab;
            --secondary-color: #f2f3ff;
            --accent-color: #e37318;
            --success-color: #00a870;
            --warning-color: #ed7b2f;
            --error-color: #d54941;
            
            /* 背景色系 */
            --bg-color-page: #f5f7fa;
            --bg-color-container: #ffffff;
            --bg-color-secondray: #f8f9fc;
            
            /* 边框和分割线 */
            --border-color: #e7e7e7;
            --border-color-light: #f0f0f0;
            --border-radius-small: 3px;
            --border-radius-medium: 6px;
            --border-radius-large: 9px;
            
            /* 文字色彩 */
            --text-primary: #1a1a1a;
            --text-secondary: #4e5969;
            --text-placeholder: #86909c;
            --text-disabled: #c9cdd4;
            
            /* 阴影系统 */
            --shadow-1: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
            --shadow-2: 0 1px 4px 0 rgba(0, 0, 0, 0.08);
            --shadow-3: 0 4px 8px 0 rgba(0, 0, 0, 0.12);
            
            /* 间距系统 */
            --space-1: 4px;
            --space-2: 8px;
            --space-3: 12px;
            --space-4: 16px;
            --space-5: 20px;
            --space-6: 24px;
            --space-8: 32px;
            --space-10: 40px;
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: "PingFang SC", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
        }
        
        body {
            background-color: var(--bg-color-page);
            color: var(--text-primary);
            font-size: 14px;
            line-height: 1.5;
            padding-bottom: 120px;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
        }
        
        .container {
            max-width: 480px;
            margin: 0 auto;
            background: var(--bg-color-container);
            min-height: 100vh;
            box-shadow: var(--shadow-1);
            position: relative;
            overflow-x: hidden;
        }
        
        /* 头部样式 - TDesign 简约风格 */
        .header {
            background: var(--primary-color);
            color: white;
            padding: var(--space-4) var(--space-4) var(--space-5);
            position: relative;
            z-index: 10;
        }
        
        .top-bar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: var(--space-4);
        }
        
        .back-btn {
            font-size: 18px;
            cursor: pointer;
            opacity: 0.9;
            transition: opacity 0.2s ease;
        }
        
        .back-btn:hover {
            opacity: 1;
        }
        
        .page-title {
            font-weight: 500;
            font-size: 16px;
        }
        
        .actions {
            display: flex;
            gap: var(--space-5);
        }
        
        .actions i {
            font-size: 16px;
            cursor: pointer;
            opacity: 0.9;
            transition: opacity 0.2s ease;
        }
        
        .actions i:hover {
            opacity: 1;
        }
        
        /* 表单区域 - TDesign 简约风格 */
        .form-container {
            padding: var(--space-5) var(--space-4);
        }
        
        .form-section {
            background: var(--bg-color-container);
            border-radius: var(--border-radius-medium);
            margin-bottom: var(--space-4);
            box-shadow: var(--shadow-1);
            overflow: hidden;
            border: 1px solid var(--border-color-light);
        }
        
        .section-header {
            padding: var(--space-4);
            border-bottom: 1px solid var(--border-color-light);
            background: var(--bg-color-secondray);
        }
        
        .section-title {
            font-size: 14px;
            font-weight: 500;
            color: var(--text-primary);
            display: flex;
            align-items: center;
        }
        
        .section-title i {
            margin-right: var(--space-2);
            color: var(--primary-color);
            font-size: 14px;
        }
        
        .form-group {
            padding: var(--space-3) var(--space-4);
            border-bottom: 1px solid var(--border-color-light);
        }
        
        .form-group:last-child {
            border-bottom: none;
        }
        
        .form-label {
            display: block;
            margin-bottom: var(--space-2);
            font-weight: 500;
            color: var(--text-primary);
            font-size: 14px;
        }
        
        .form-input {
            width: 100%;
            padding: var(--space-3);
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius-medium);
            font-size: 14px;
            background: var(--bg-color-container);
            transition: all 0.2s ease;
        }
        
        .form-input:focus {
            outline: none;
            border-color: var(--primary-color);
            box-shadow: 0 0 0 2px rgba(0, 82, 217, 0.1);
        }
        
        .form-textarea {
            width: 100%;
            padding: var(--space-3);
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius-medium);
            font-size: 14px;
            background: var(--bg-color-container);
            resize: vertical;
            min-height: 80px;
            font-family: inherit;
            transition: all 0.2s ease;
        }
        
        .form-textarea:focus {
            outline: none;
            border-color: var(--primary-color);
            box-shadow: 0 0 0 2px rgba(0, 82, 217, 0.1);
        }
        
        .form-select {
            width: 100%;
            padding: var(--space-3);
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius-medium);
            font-size: 14px;
            background: var(--bg-color-container);
            cursor: pointer;
            transition: all 0.2s ease;
        }
        
        .form-select:focus {
            outline: none;
            border-color: var(--primary-color);
            box-shadow: 0 0 0 2px rgba(0, 82, 217, 0.1);
        }
        
        .upload-area {
            border: 2px dashed var(--border-color);
            border-radius: var(--border-radius-medium);
            padding: var(--space-8);
            text-align: center;
            cursor: pointer;
            transition: all 0.2s ease;
            background: var(--bg-color-secondray);
        }
        
        .upload-area:hover {
            border-color: var(--primary-color);
            background: var(--secondary-color);
        }
        
        .upload-area i {
            font-size: 32px;
            color: var(--text-placeholder);
            margin-bottom: var(--space-2);
        }
        
        .upload-text {
            color: var(--text-secondary);
            font-size: 14px;
        }
        
        .upload-hint {
            color: var(--text-placeholder);
            font-size: 12px;
            margin-top: var(--space-1);
        }
        
        .tag-container {
            display: flex;
            flex-wrap: wrap;
            gap: var(--space-2);
            margin-top: var(--space-2);
        }
        
        .tag {
            background: var(--bg-color-secondray);
            color: var(--text-secondary);
            padding: var(--space-1) var(--space-3);
            border-radius: var(--border-radius-small);
            font-size: 12px;
            cursor: pointer;
            transition: all 0.2s cubic-bezier(0.34, 0.69, 0.1, 1);
            border: 1px solid var(--border-color-light);
        }
        
        .tag:hover {
            background: var(--primary-color);
            color: white;
            border-color: var(--primary-color);
        }
        
        .tag.selected {
            background: var(--primary-color);
            color: white;
            border-color: var(--primary-color);
        }
        
        /* 底部操作栏 - TDesign 简约风格 */
        .bottom-actions {
            position: fixed;
            bottom: 64px;
            left: 0;
            right: 0;
            background: var(--bg-color-container);
            padding: var(--space-4);
            border-top: 1px solid var(--border-color-light);
            display: flex;
            gap: var(--space-2);
            z-index: 100;
            max-width: 480px;
            margin: 0 auto;
        }
        
        .btn {
            flex: 1;
            padding: var(--space-3);
            border: none;
            border-radius: var(--border-radius-medium);
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s ease;
        }
        
        .btn-secondary {
            background: var(--bg-color-secondray);
            color: var(--text-secondary);
            border: 1px solid var(--border-color-light);
        }
        
        .btn-secondary:hover {
            background: var(--border-color-light);
        }
        
        .btn-primary {
            background: var(--primary-color);
            color: white;
        }
        
        .btn-primary:hover {
            background: var(--primary-light);
        }
        
        /* 底部导航栏 - TDesign 简约风格 */
        .tabbar {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            background: var(--bg-color-container);
            border-top: 1px solid var(--border-color);
            display: flex;
            z-index: 100;
            max-width: 480px;
            margin: 0 auto;
            height: 64px;
        }
        
        .tab-item {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: var(--space-2) 0;
            cursor: pointer;
            transition: color 0.2s ease;
            color: var(--text-placeholder);
        }
        
        .tab-item.active {
            color: var(--primary-color);
        }
        
        .tab-item:hover {
            color: var(--primary-light);
        }
        
        .tab-item i {
            font-size: 18px;
            margin-bottom: var(--space-1);
        }
        
        .tab-item span {
            font-size: 10px;
        }
        
        /* 提示信息 */
        .form-hint {
            color: var(--text-light);
            font-size: 12px;
            margin-top: 5px;
        }
        
        .required {
            color: #ff4757;
        }
        
        /* 下拉输入框样式 */
        .input-with-dropdown {
            position: relative;
            display: flex;
            align-items: center;
        }
        
        .input-with-dropdown .form-input {
            padding-right: 40px;
        }
        
        .dropdown-icon {
            position: absolute;
            right: 12px;
            color: var(--text-light);
            font-size: 14px;
            pointer-events: none;
        }
        
        /* 规格/数量字段样式 */
        .spec-container {
            display: flex;
            flex-direction: column;
            gap: var(--space-3); /* 行间距 */
        }
        
        .spec-item {
            display: flex;
            align-items: center;
            background: var(--bg-color-container);
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius-medium);
            overflow: hidden;
            transition: all 0.2s ease;
            height: 36px; /* TDesign标准高度 */
            min-width: 100px; /* 最小宽度 */
        }
        
        .spec-item:focus-within {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 2px rgba(0, 82, 217, 0.1);
        }
        
        .spec-input {
            border: none;
            padding: var(--space-3); /* TDesign标准内边距 */
            font-size: 14px; /* TDesign标准字体大小 */
            background: transparent;
            width: 70px; /* 合理的输入框宽度 */
            outline: none;
            height: 100%;
            flex: 1;
        }
        
        .spec-input::placeholder {
            color: var(--text-placeholder);
        }
        
        .spec-unit {
            padding: var(--space-2) var(--space-3); /* TDesign标准内边距 */
            background: var(--bg-color-secondray);
            color: var(--text-secondary);
            font-size: 12px; /* 合理的单位字体大小 */
            border-left: 1px solid var(--border-color-light);
            min-width: 32px; /* 合理的单位标签宽度 */
            text-align: center;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 500;
        }
        
        .add-spec-btn {
            width: 36px; /* 与规格项高度一致 */
            height: 36px; /* 与规格项高度一致 */
            border: 1px solid var(--primary-color);
            border-radius: 50%;
            background: var(--primary-color);
            color: white;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s ease;
            font-size: 14px;
            flex-shrink: 0; /* 防止按钮被压缩 */
        }
        
        .add-spec-btn:hover {
            background: var(--primary-light);
            transform: scale(1.05);
        }
        
        .remove-spec-btn {
            width: 28px; /* 适中的删除按钮尺寸 */
            height: 28px; /* 适中的删除按钮尺寸 */
            border: 1px solid var(--error-color);
            border-radius: 50%;
            background: var(--error-color);
            color: white;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s ease;
            font-size: 12px;
            margin-left: var(--space-2);
            flex-shrink: 0; /* 防止按钮被压缩 */
        }
        
        .remove-spec-btn:hover {
            background: #c0392b;
            transform: scale(1.05);
        }
        
        /* 地址三级联动 */
        .address-group {
            display: flex;
            flex-direction: column;
            gap: var(--space-2);
        }
        
        .address-row {
            display: flex;
            gap: var(--space-2);
        }
        
        .address-select {
            flex: 1;
        }
    </style>
</head>
<body>
    <div class="container">
        <!-- 头部区域 -->
        <div class="header">
            <div class="top-bar">
                <div class="back-btn" onclick="history.back()">
                    <i class="fas fa-arrow-left"></i>
                </div>
                <div class="page-title">发布拼单</div>
                <div class="actions">
                </div>
            </div>
        </div>
        
        <!-- 表单区域 -->
        <div class="form-container">
            <!-- 拼单信息 -->
            <div class="form-section">
                <div class="section-header">
                    <div class="section-title">
                        <i class="fas fa-users"></i>
                        拼单信息
                    </div>
                </div>
                
                
                
                
                <div class="form-group">
                    <label class="form-label">产品类别 <span class="required">*</span></label>
                    <div class="input-with-dropdown">
                        <input type="text" class="form-input" placeholder="请选择产品类别">
                        <i class="fas fa-chevron-down dropdown-icon"></i>
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="form-label">产品名称 <span class="required">*</span></label>
                    <div class="input-with-dropdown">
                        <input type="text" class="form-input" placeholder="请选择产品名称">
                        <i class="fas fa-chevron-down dropdown-icon"></i>
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="form-label">型号 <span class="required">*</span></label>
                    <input type="text" class="form-input" placeholder="请输入产品型号">
                </div>
                
                <div class="form-group">
                    <label class="form-label">规格/数量 <span class="required">*</span></label>
                    <div class="spec-container">
                        <div class="spec-row" style="display: flex; gap: var(--space-2); align-items: center;">
                            <div class="spec-item">
                                <input type="number" class="spec-input" placeholder="0">
                                <span class="spec-unit">mm</span>
                            </div>
                            <div class="spec-item">
                                <input type="number" class="spec-input" placeholder="0">
                                <span class="spec-unit">m</span>
                            </div>
                            <button type="button" class="add-spec-btn" onclick="addSpecItem()">
                                <i class="fas fa-plus"></i>
                            </button>
                        </div>
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="form-label">所在地 <span class="required">*</span></label>
                    <div class="address-group">
                        <div class="address-row">
                            <select class="form-select address-select" id="province">
                                <option value="">请选择省份</option>
                                <option value="beijing">北京市</option>
                                <option value="shanghai">上海市</option>
                                <option value="guangdong">广东省</option>
                                <option value="jiangsu">江苏省</option>
                                <option value="zhejiang">浙江省</option>
                                <option value="other">其他</option>
                            </select>
                            <select class="form-select address-select" id="city">
                                <option value="">请选择城市</option>
                            </select>
                        </div>
                        <div class="address-row">
                            <select class="form-select address-select" id="district">
                                <option value="">请选择区县</option>
                            </select>
                        </div>
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="form-label">总量 <span class="required">*</span></label>
                    <input type="number" class="form-input" placeholder="请输入总量">
                </div>
                
                <div class="form-group">
                    <label class="form-label">上传技术参数</label>
                    <div class="upload-area">
                        <i class="fas fa-cloud-upload-alt"></i>
                        <div class="upload-text">点击上传文件 (0/1)</div>
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="form-label">备注</label>
                    <textarea class="form-textarea" placeholder="请输入备注信息"></textarea>
                </div>
            </div>
            
            <!-- 联系方式 -->
            <div class="form-section">
                <div class="section-header">
                    <div class="section-title">
                        <i class="fas fa-phone"></i>
                        联系方式
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="form-label">联系人 <span class="required">*</span></label>
                    <input type="text" class="form-input" id="contactName" placeholder="请输入联系人姓名" value="张经理">
                </div>
                
                <div class="form-group">
                    <label class="form-label">联系电话 <span class="required">*</span></label>
                    <input type="tel" class="form-input" id="contactPhone" placeholder="请输入联系电话" value="13800138000">
                </div>
                
                <div class="form-group">
                    <label class="form-label">邮箱</label>
                    <input type="email" class="form-input" placeholder="请输入邮箱地址（可选）">
                </div>
            </div>
        </div>
        
        <!-- 底部操作栏 -->
        <div class="bottom-actions">
            <button class="btn btn-primary">发布拼单</button>
        </div>
        
        <!-- 底部导航 -->
        <div class="tabbar">
            <div class="tab-item">
                <i class="fas fa-home"></i>
                <span>首页</span>
            </div>
            <div class="tab-item">
                <i class="fas fa-search"></i>
                <span>求购</span>
            </div>
            <div class="tab-item active">
                <i class="fas fa-plus-circle"></i>
                <span>发布</span>
            </div>
            <div class="tab-item" onclick="location.href='consultation.html'">
                <i class="fas fa-comments"></i>
                <span>客服</span>
            </div>
            <div class="tab-item">
                <i class="fas fa-user"></i>
                <span>我的</span>
            </div>
        </div>
    </div>
    
    <script>
        // 规格/数量管理
        let specCounter = 2; // 初始已有2个规格项
        
        function addSpecItem() {
            const specContainer = document.querySelector('.spec-container');
            
            // 创建一行包含mm和m的规格项
            const specRow = document.createElement('div');
            specRow.className = 'spec-row';
            specRow.style.cssText = 'display: flex; gap: var(--space-2); align-items: center;';
            
            // 创建mm规格项
            const mmItem = document.createElement('div');
            mmItem.className = 'spec-item';
            mmItem.innerHTML = `
                <input type="number" class="spec-input" placeholder="0">
                <span class="spec-unit">mm</span>
            `;
            
            // 创建m规格项
            const mItem = document.createElement('div');
            mItem.className = 'spec-item';
            mItem.innerHTML = `
                <input type="number" class="spec-input" placeholder="0">
                <span class="spec-unit">m</span>
            `;
            
            // 创建删除按钮
            const removeBtn = document.createElement('button');
            removeBtn.type = 'button';
            removeBtn.className = 'remove-spec-btn';
            removeBtn.style.cssText = 'margin-left: 8px;';
            removeBtn.innerHTML = '<i class="fas fa-times"></i>';
            removeBtn.onclick = function() { removeSpecRow(this); };
            
            // 组装行
            specRow.appendChild(mmItem);
            specRow.appendChild(mItem);
            specRow.appendChild(removeBtn);
            
            // 在第一行后插入新行
            const firstRow = specContainer.querySelector('.spec-row');
            specContainer.insertBefore(specRow, firstRow.nextSibling);
            specCounter++;
        }
        
        function removeSpecItem(button) {
            const specItem = button.parentElement;
            specItem.remove();
            specCounter--;
        }
        
        function removeSpecRow(button) {
            const specRow = button.parentElement;
            specRow.remove();
            specCounter--;
        }
        
        // 文件上传
        document.querySelectorAll('.upload-area').forEach(area => {
            area.addEventListener('click', function() {
                // 这里可以添加文件上传逻辑
                console.log('上传文件');
            });
        });
        
        // 底部导航切换
        document.querySelectorAll('.tab-item').forEach(item => {
            item.addEventListener('click', function() {
                document.querySelectorAll('.tab-item').forEach(t => t.classList.remove('active'));
                this.classList.add('active');
            });
        });
        
        // 表单验证
        document.querySelector('.btn-primary').addEventListener('click', function() {
            const requiredFields = document.querySelectorAll('.form-input[placeholder*="请输入"], .form-textarea[placeholder*="请输入"]');
            let isValid = true;
            
            requiredFields.forEach(field => {
                if (!field.value.trim()) {
                    field.style.borderColor = '#ff4757';
                    isValid = false;
                } else {
                    field.style.borderColor = 'var(--border-color)';
                }
            });
            
            if (isValid) {
                showPublishSuccessModal();
            } else {
                alert('请填写必填项');
            }
        });
        
        // 显示发布成功模态框
        function showPublishSuccessModal() {
            // 创建模态框背景
            const modalOverlay = document.createElement('div');
            modalOverlay.style.cssText = `
                position: fixed;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                background: rgba(0, 0, 0, 0.5);
                z-index: 1000;
                display: flex;
                align-items: center;
                justify-content: center;
                padding: 20px;
            `;
            
            // 创建模态框内容
            const modalContent = document.createElement('div');
            modalContent.style.cssText = `
                background: white;
                border-radius: 12px;
                padding: 24px;
                max-width: 320px;
                width: 100%;
                text-align: center;
                box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
            `;
            
            modalContent.innerHTML = `
                <div style="margin-bottom: 20px;">
                    <div style="width: 60px; height: 60px; background: #00a870; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px;">
                        <i class="fas fa-check" style="color: white; font-size: 24px;"></i>
                    </div>
                    <h3 style="font-size: 18px; font-weight: 500; color: #1a1a1a; margin-bottom: 8px;">发布完成</h3>
                    <p style="font-size: 14px; color: #4e5969; line-height: 1.5;">您的拼单已成功发布，等待其他用户参与拼单</p>
                </div>
                <div style="display: flex; gap: 12px;">
                    <button id="viewDetailBtn" style="flex: 1; padding: 12px; border: 1px solid #e7e7e7; border-radius: 6px; background: white; color: #4e5969; font-size: 14px; cursor: pointer; transition: all 0.2s;">
                        查看详情
                    </button>
                    <button id="continuePublishBtn" style="flex: 1; padding: 12px; border: none; border-radius: 6px; background: #0052d9; color: white; font-size: 14px; cursor: pointer; transition: all 0.2s;">
                        继续发布
                    </button>
                </div>
            `;
            
            modalOverlay.appendChild(modalContent);
            document.body.appendChild(modalOverlay);
            
            // 添加按钮事件
            document.getElementById('viewDetailBtn').addEventListener('click', function() {
                document.body.removeChild(modalOverlay);
                // 跳转到拼单详情页
                location.href = 'group-detail.html';
            });
            
            document.getElementById('continuePublishBtn').addEventListener('click', function() {
                document.body.removeChild(modalOverlay);
                // 跳转到发布首页
                location.href = 'publish-select.html';
            });
            
            // 点击背景关闭模态框
            modalOverlay.addEventListener('click', function(e) {
                if (e.target === modalOverlay) {
                    document.body.removeChild(modalOverlay);
                }
            });
            
            // 添加按钮悬停效果
            const viewDetailBtn = document.getElementById('viewDetailBtn');
            const continuePublishBtn = document.getElementById('continuePublishBtn');
            
            viewDetailBtn.addEventListener('mouseenter', function() {
                this.style.borderColor = '#0052d9';
                this.style.color = '#0052d9';
            });
            
            viewDetailBtn.addEventListener('mouseleave', function() {
                this.style.borderColor = '#e7e7e7';
                this.style.color = '#4e5969';
            });
            
            continuePublishBtn.addEventListener('mouseenter', function() {
                this.style.background = '#266fe8';
            });
            
            continuePublishBtn.addEventListener('mouseleave', function() {
                this.style.background = '#0052d9';
            });
        }
        
        // 地址三级联动数据
        const addressData = {
            'beijing': {
                'beijing': ['东城区', '西城区', '朝阳区', '丰台区', '石景山区', '海淀区', '门头沟区', '房山区', '通州区', '顺义区', '昌平区', '大兴区', '怀柔区', '平谷区', '密云区', '延庆区']
            },
            'shanghai': {
                'shanghai': ['黄浦区', '徐汇区', '长宁区', '静安区', '普陀区', '虹口区', '杨浦区', '闵行区', '宝山区', '嘉定区', '浦东新区', '金山区', '松江区', '青浦区', '奉贤区', '崇明区']
            },
            'guangdong': {
                'guangzhou': ['荔湾区', '越秀区', '海珠区', '天河区', '白云区', '黄埔区', '番禺区', '花都区', '南沙区', '从化区', '增城区'],
                'shenzhen': ['罗湖区', '福田区', '南山区', '宝安区', '龙岗区', '盐田区', '龙华区', '坪山区', '光明区', '大鹏新区']
            },
            'jiangsu': {
                'nanjing': ['玄武区', '秦淮区', '建邺区', '鼓楼区', '浦口区', '栖霞区', '雨花台区', '江宁区', '六合区', '溧水区', '高淳区'],
                'suzhou': ['虎丘区', '吴中区', '相城区', '姑苏区', '吴江区', '常熟市', '张家港市', '昆山市', '太仓市']
            },
            'zhejiang': {
                'hangzhou': ['上城区', '下城区', '江干区', '拱墅区', '西湖区', '滨江区', '萧山区', '余杭区', '富阳区', '临安区', '桐庐县', '淳安县', '建德市']
            }
        };
        
        // 地址三级联动功能
        function initAddressSelect() {
            const provinceSelect = document.getElementById('province');
            const citySelect = document.getElementById('city');
            const districtSelect = document.getElementById('district');
            
            // 省份变化时更新城市
            provinceSelect.addEventListener('change', function() {
                const province = this.value;
                citySelect.innerHTML = '<option value="">请选择城市</option>';
                districtSelect.innerHTML = '<option value="">请选择区县</option>';
                
                if (province && addressData[province]) {
                    Object.keys(addressData[province]).forEach(city => {
                        const option = document.createElement('option');
                        option.value = city;
                        option.textContent = city === 'beijing' ? '北京市' : 
                                          city === 'shanghai' ? '上海市' :
                                          city === 'guangzhou' ? '广州市' :
                                          city === 'shenzhen' ? '深圳市' :
                                          city === 'nanjing' ? '南京市' :
                                          city === 'suzhou' ? '苏州市' :
                                          city === 'hangzhou' ? '杭州市' : city;
                        citySelect.appendChild(option);
                    });
                }
            });
            
            // 城市变化时更新区县
            citySelect.addEventListener('change', function() {
                const province = provinceSelect.value;
                const city = this.value;
                districtSelect.innerHTML = '<option value="">请选择区县</option>';
                
                if (province && city && addressData[province] && addressData[province][city]) {
                    addressData[province][city].forEach(district => {
                        const option = document.createElement('option');
                        option.value = district;
                        option.textContent = district;
                        districtSelect.appendChild(option);
                    });
                }
            });
        }
        
        // 初始化地址三级联动
        initAddressSelect();
    </script>
</body>
</html>


